/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.LinkedList;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 *
 * @author Mark
 */
@Entity
public class Category implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    protected String CatName;
    protected String ebayID;
    protected String parentID;
    @OneToMany(cascade={CascadeType.PERSIST})
    protected Collection<Category> sottoCategorie;
    protected String catLevel;

    public Category(String CatName, String ebayID, String parentID, Collection<Category> sottoCategorie, String catLevel) {
        this.CatName = CatName;
        this.ebayID = ebayID;
        this.parentID = parentID;
        this.sottoCategorie = sottoCategorie;
        this.catLevel = catLevel;
    }

    public Category() {
        this("","","","");
    }

    public Category(String CatName, String ebayID, String parentID, String catLevel) {
        this.CatName = CatName;
        this.ebayID = ebayID;
        this.parentID = parentID;
        this.catLevel = catLevel;
        this.sottoCategorie = new LinkedList<Category>();
    }



    /**
     * Get the value of catLevel
     *
     * @return the value of catLevel
     */
    public String getCatLevel() {
        return catLevel;
    }

    /**
     * Set the value of catLevel
     *
     * @param catLevel new value of catLevel
     */
    public void setCatLevel(String catLevel) {
        this.catLevel = catLevel;
    }

    /**
     * Get the value of sottoCategorie
     *
     * @return the value of sottoCategorie
     */
    public Collection<Category> getSottoCategorie() {
        return sottoCategorie;
    }

    /**
     * Set the value of sottoCategorie
     *
     * @param sottoCategorie new value of sottoCategorie
     */
    public void setSottoCategorie(Collection<Category> sottoCategorie) {
        this.sottoCategorie = sottoCategorie;
    }


    public Long getId() {
        return id;
    }

    /**
     * Get the value of parentID
     *
     * @return the value of parentID
     */
    public String getParentID() {
        return parentID;
    }

    /**
     * Set the value of parentID
     *
     * @param parentID new value of parentID
     */
    public void setParentID(String parentID) {
        this.parentID = parentID;
    }

    /**
     * Get the value of ebayID
     *
     * @return the value of ebayID
     */
    public String getEbayID() {
        return ebayID;
    }

    /**
     * Get the value of CatName
     *
     * @return the value of CatName
     */
    public String getCatName() {
        return CatName;
    }

    /**
     * Set the value of CatName
     *
     * @param CatName new value of CatName
     */
    public void setCatName(String CatName) {
        this.CatName = CatName;
    }

    /**
     * Set the value of ebayID
     *
     * @param ebayID new value of ebayID
     */
    public void setEbayID(String ebayID) {
        this.ebayID = ebayID;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Category)) {
            return false;
        }
        Category other = (Category) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Category[id=" + id + "Eid="+ebayID+ "lvl="+catLevel+ "]";
    }
}
